import { defineStore } from 'pinia'

export const useStore = defineStore('store', {
    state: () => {
        return {
            userRouter: null,
            isShow: false,
            isAcitve: 0,
            num: 0,
        }
    },
    actions: {
        getRouter(value) {
            this.userRouter = value
        },
        getShow(value) {
            this.isShow = value
        },
        getAcitve(value) {
            this.isAcitve = value
        },
        getNum(value) {
            this.num = value
        },
        // 清除数据
       getClearData() {
            this.userRouter = null
            this.isShow = false
            this.isAcitve = 0
            this.num = 0
          
            
        },
        // 获取我的所有路由
        getAllRouter(value) {
            this.myRouterList = value;
        }
    },
    persist: {
        enabled: true,   // 表示启用数据持久化
        strategies: [
            // isCollapsed字段用 localstorage存储
            {
                storage: localStorage,
                key: "getRouter",
            },
            {
                storage: localStorage,
                key: "getAllRouter",
            },

        ]
    },

})